package me.zhengjie.utils;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class aaa {
    public  static  void main(String[] args) throws IOException {
        //获取背景路径
        File fiels = new File("D:\\360Downloads\\test1.jpg");
        //图片输出路径
        File outfiels = new File("D:\\360Downloads\\ttt.jpg");

        BufferedImage bgImg = ImageIO.read(fiels);
        Graphics2D g = bgImg.createGraphics();
        BufferedImage MemberQR = ImageIO.read(new File("D:\\360Downloads\\circle_ring.jpg"));
        g.drawImage(MemberQR,100,100,800,800, null);

        BufferedImage a1QR = ImageIO.read(new File("D:\\360Downloads\\a1.jpg"));
        g.drawImage(a1QR,100,100,800,800, null);

        BufferedImage a3R = ImageIO.read(new File("D:\\360Downloads\\a3.png"));
        g.drawImage(a3R,470,250,300,300, null);


        try {
            // 加载自定义的TTF字体文件
            Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File("D:\\360Downloads/腾祥魅黑简.ttf")).deriveFont(150f); // 调整字体大小
            g.setFont(customFont);
        } catch (Exception e) {
            System.out.println("Error loading font: " + e.getMessage());
            return;
        }
        // 绘制艺术字
        g.setColor(Color.BLACK);
        g.drawString("李", 560, 450);

        try {
            // 加载自定义的TTF字体文件
            Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File("D:\\360Downloads/腾祥魅黑简.ttf")).deriveFont(75f); // 调整字体大小
            g.setFont(customFont);
        } catch (Exception e) {
            System.out.println("Error loading font: " + e.getMessage());
            return;
        }
        // 绘制艺术字
        g.setColor(Color.BLACK);
        g.drawString("晴空万李", 475, 650); // 在图片中心位置绘制文字

        ImageIO.write(bgImg, "png", outfiels);
    }
}
